\doxysection{x\+Queue\+Overwrite }
\hypertarget{group__x_queue_overwrite}{}\label{group__x_queue_overwrite}\index{xQueueOverwrite@{xQueueOverwrite}}
queue. h 
\begin{DoxyPre}
 BaseType\_t xQueueOverwrite(                               QueueHandle\_t xQueue,                               const void * pvItemToQueue                          );
   \end{DoxyPre}


Only for use with queues that have a length of one -\/ so the queue is either empty or full.

Post an item on a queue. If the queue is already full then overwrite the value held in the queue. The item is queued by copy, not by reference.

This function must not be called from an interrupt service routine. See x\+Queue\+Overwrite\+From\+ISR () for an alternative which may be used in an ISR.


\begin{DoxyParams}{Parameters}
{\em x\+Queue} & The handle of the queue to which the data is being sent.\\
\hline
{\em pv\+Item\+To\+Queue} & A pointer to the item that is to be placed on the queue. The size of the items the queue will hold was defined when the queue was created, so this many bytes will be copied from pv\+Item\+To\+Queue into the queue storage area.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
x\+Queue\+Overwrite() is a macro that calls x\+Queue\+Generic\+Send(), and therefore has the same return values as x\+Queue\+Send\+To\+Front(). However, pd\+PASS is the only value that can be returned because x\+Queue\+Overwrite() will write to the queue even when the queue is already full.
\end{DoxyReturn}
Example usage\+: 
\begin{DoxyPre}

 void vFunction( void *pvParameters )
 \{
 QueueHandle\_t xQueue;
 uint32\_t ulVarToSend, ulValReceived;

    // Create a queue to hold one uint32\_t value.  It is strongly
    // recommended *not* to use xQueueOverwrite() on queues that can
    // contain more than one value, and doing so will trigger an assertion
    // if configASSERT() is defined.
    xQueue = xQueueCreate( 1, sizeof( uint32\_t ) );

    // Write the value 10 to the queue using xQueueOverwrite().
    ulVarToSend = 10;
    xQueueOverwrite( xQueue, \&ulVarToSend );

    // Peeking the queue should now return 10, but leave the value 10 in
    // the queue.  A block time of zero is used as it is known that the
    // queue holds a value.
    ulValReceived = 0;
    xQueuePeek( xQueue, \&ulValReceived, 0 );

    if( ulValReceived != 10 )
    \{
        // Error unless the item was removed by a different task.
    \}

    // The queue is still full.  Use xQueueOverwrite() to overwrite the
    // value held in the queue with 100.
    ulVarToSend = 100;
    xQueueOverwrite( xQueue, \&ulVarToSend );

    // This time read from the queue, leaving the queue empty once more.
    // A block time of 0 is used again.
    xQueueReceive( xQueue, \&ulValReceived, 0 );

    // The value read should be the last value written, even though the
    // queue was already full when the value was written.
    if( ulValReceived != 100 )
    \{
        // Error!
    \}

    // ...
\}
 \end{DoxyPre}
 